﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tracy.DataModel.Config;
using SharedLib.XmlDataModel;
using System.Xml;

namespace Tracy.Plugins.DownloadAdapters.Model
{
    public class UTorrentConfiguration : XmlDataModelWithAttributes, IConfigModel
    {
        public UTorrentConfiguration(XmlNode node) : base(node) {  }
        public UTorrentConfiguration() : base() {  }

        public override string RootNodeName
        {
            get
            {
                return "config";
            }
        }

        /// <summary>
        /// UserName
        /// </summary>
        public string UserName
        {
            get { return Properties["username"]; }
            set { Properties["username"] = value; }
        }

        /// <summary>
        /// Password
        /// </summary>
        public string Password
        {
            get 
            { 
                return SharedLib.Helpers.SecurityHelper.DecryptString(Properties["password"], "Tracy_uTorrent_Adapter"); 
            }
            set 
            { 
                Properties["password"] = SharedLib.Helpers.SecurityHelper.EncryptString(value, "Tracy_uTorrent_Adapter"); 
            }
        }

        /// <summary>
        /// Port
        /// </summary>
        public string Port
        {
            get { return Properties["port"]; }
            set { Properties["port"] = value; }
        }
    }
}
